from selenium.webdriver.common.by import By
from Base import Base
class Page2(Base):
    # 定位器
    #首页的定位
    sy_loc=(By.XPATH,'//a[@href="/home/login.html"]')
    #封装页面
    def shouye(self):
        self.click(self.sy_loc)
    #搜索框的定位
    search_loc=(By.TAG_NAME,'input')
    def search(self):
        self.send_keys(self.search_loc,'豪士小面包')
    #对搜索按钮进行点击
    sousuobtn_loc=(By.CLASS_NAME,'search-input-btn')
    def sousuobtn(self):
        self.click(self.sousuobtn_loc)
    # 对豪士小面包进行点击操作
    hs_loc=(By.XPATH,'//img[@src="/uploads/images/20251017/42392b51b2447832a2bf8debf99c6d2e.png"]')
    def haoshixiaomianbao(self):
        self.click(self.hs_loc)
    #断言文本：豪士小面包
    dy2_loc=(By.XPATH, "//*[text()='豪士小面包']")
    def dy2(self):
        return self.text(self.dy2_loc)
    #断言：商品价格
    dy3_loc=(By.ID,'sell-price-box')
    def dy3(self):
         return self.text(self.dy3_loc)
    #立即购买按钮的定位
    ljgmbtn_loc=(By.ID,'buy-cart')
    def lijigoumai(self):
        self.click(self.ljgmbtn_loc)
    #断言：确认订单信息
    dy4_loc = (By.XPATH,'/html/body/div[4]/div[2]/ul/li[2]/em')
    def dy4(self):
        return self.text(self.dy4_loc)
    #自提按钮的定位
    ziti_loc = (By.ID,'store-1')
    def ziti(self):
        self.click(self.ziti_loc)
    #下一步的定位
    xiayibu_loc = (By.ID,'order-button')
    def xiayibu(self):
        self.click(self.xiayibu_loc)
    dy5_loc = (By.XPATH,'/html/body/div[4]/div[2]/ul/li[3]/em')
    def dy5(self):
        return self.text(self.dy5_loc)
    # 业务逻辑
    def luoji_A3mall2(self):
        self.shouye()
        self.search()
        self.sousuobtn()
        self.haoshixiaomianbao()
        print(self.dy2())
        print(self.dy3())
        self.lijigoumai()
        print(self.dy4())
        self.ziti()
        self.xiayibu()
        print(self.dy5())
